﻿using System.Collections.Generic;
using System.Drawing;
using GIMS.Def.Arguments;
using GIMS.Def.Operators;
using GIMS.Def.Settings;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Linq;

namespace GIMS.Def.Test
{
    /// <summary>
    ///This is a test class for LabelOperatorTest and is intended
    ///to contain all LabelOperatorTest Unit Tests
    ///</summary>
    [TestClass()]
    public class LabelOperatorTest
    {
        /// <summary>
        /// Reset GlobalSettings
        /// </summary>
        [TestInitialize()]
        public void MyTestInitialize()
        {
            GlobalSettings_Accessor.instance = null;
        }

        /// <summary>
        ///A test for CreateScriptPart of LabelOperator
        ///</summary>
        [TestMethod()]
        public void CreateScriptPartTest()
        {
            LabelOperator target = new LabelOperator();
            LiteralArgument arg = (LiteralArgument)target.Argument;
            arg.Text = "hello";
            Assert.AreEqual("label:\"hello\"",target.CreateScriptPart());
        }

        /// <summary>
        ///A test for CreateScriptPart of LabelOperator (with Setting)
        ///</summary>
        [TestMethod()]
        public void CreateScriptPartTest2()
        {
            LabelOperator target = new LabelOperator();
            LiteralArgument arg = (LiteralArgument)target.Argument;
            arg.Text = "hello";
            List<Setting> settings = target.Settings;
            FillSetting fs=(FillSetting)(settings.First(x => x.Name.Equals("Fill")));
            fs.Active = true;
            GlobalSettings.Instance.Settings.First(x => x.Name.Equals("Fill")).Active = true;
            ColorArgument arg2 = (ColorArgument) fs.Argument;
            arg2.Color = Color.Red;
            
            Assert.AreEqual("-fill rgba(255,0,0,1) label:\"hello\" -fill rgba(0,0,0,1)", target.CreateScriptPart());
        }
    }
}
